<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/admin/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>更改用户密码</title>

<link rel="stylesheet" type="text/css" href="../css/backCss.css" />

<script language="JavaScript" type="text/javascript">
	var flag_old = false;
	var flaga = false;
	var flagb = false;

	function check() {
		if (!flag_old) {
			alert("旧密码输入不正确啦");
			return false;
		}
		if (!flaga || !flagb) {
			alert("修改之前请确定参数都设置正确了");
			return false;
		}
		return true;
	}
	function checkPass(password) {
		var passwordSpam = document.getElementById("passwordSpan");
		if (!(/^[a-zA-Z0-9]{6,20}$/.test(password.value))) {
			flaga = false;
			passwordSpam.innerHTML = "<font color=\"red\">× 密码由'6-20'位的字母/数字组成</font>";
		} else {
			flaga = true;
			passwordSpam.innerHTML = "<font color=\"blue\">√ 正确</font>";
		}
	}
	function checkAffirmPass() {
		var password = document.getElementById("password").value;
		var affirmPassword = document.getElementById("affirmPassword").value;
		var affirmPasswordSpam = document.getElementById("affirmPasswordSpan");
		if (!(/^[a-zA-Z0-9]{6,30}$/.test(affirmPassword))) {
			flagb = false;
			affirmPasswordSpam.innerHTML = "<font color=\"red\">× 密码由'6-30'位的字母/数字组成</font>";
		} else {
			if (password == affirmPassword) {
				flagb = true;
				affirmPasswordSpam.innerHTML = "<font color=\"blue\">√ 正确</font>"
			} else {
				flagb = false;
				affirmPasswordSpam.innerHTML = "<font color=\"red\">× 两次密码不一致</font>"
			}
		}
	}

	function checkOldPassword(oldPassword) {
		if (oldPassword.value != "") {

		} else {
			flag_old = false;
			document.getElementById("oldPasswordSpan").innerHTML = "<font color='red'>密码不能为空</font>";
		}
	}
</script>

</head>
<body class="ContentBody">
	<div class="top" align="center">
		<jsp:include page="top.jsp"></jsp:include>
	</div>
	<div class="content" align="center">
		<div align="center">
			<form action="UserServlet" method="post" name="updatePassForm">
				<div class="MainDiv">
					<table width="60%" border="0" cellpadding="0" cellspacing="0"
						class="CContent">
						<tr>
							<th class="tablestyle_title">修改个人密码</th>
						</tr>
						<tr style="background: #F0FFF0">
							<td class="CPanel">
								<table border="0" cellpadding="0" cellspacing="0"
									style="width: 100%">
									<tr>
										<td width="100%">
											<fieldset style="height: 100%;">
												<legend> 修改个人密码 </legend>
												<table border="0" align="center" cellpadding="2"
													cellspacing="1">
													<tr>
														<td colspan="2" align="center"><font color="red"
															style="font-style: italic"> <strong><s:actionerror />
															</strong>
														</font></td>
													</tr>
													<tr>
														<td align="right" width="20%"><span class="red"><font
																color="red">*</font>
														</span>旧的密码:</td>
														<td width="35%"><input name='oldPassword'
															id='oldPassword' type="password" class="text" size="30"
															onblur="checkOldPassword(this)" /> <span
															id="oldPasswordSpan"></span></td>
													</tr>

													<tr>
														<td align="right" width="20%"><span class="red"><font
																color="red">*</font>
														</span>新的密码:</td>
														<td width="35%"><input name='password' id="password"
															type="password" class="text" size="30"
															onblur="checkPass(this)" /> <span id="passwordSpan"></span>
														</td>
													</tr>
													<tr>
														<td align="right" width="20%"><span class="red"><font
																color="red">*</font>
														</span>确认密码:</td>
														<td width="35%"><input name='affirmPassword'
															id="affirmPassword" type="password" class="text"
															size="30" onblur="checkAffirmPass()" /> <span
															id="affirmPasswordSpan"></span></td>
													</tr>
													<tr>
														<td colspan="2" align="center" height="50px"><input
															type="submit" name="Submit" value="修改" class="button"
															onclick="return check()" /> <input type="button"
															name="Submit2" value="返回" class="button"
															onclick="window.history.go(-1);" /></td>
													</tr>
												</table>
											</fieldset></td>
									</tr>
								</table></td>
						</tr>
					</table>
				</div>
			</form>
		</div>
	</div>
	<div class="foot" align="center">
		<jsp:include page="foot.jsp"></jsp:include>
	</div>
</body>
</html>

